//
//  NormalTableViewCell.m
//  SnailPost
//
//  Created by Q on 16/3/11.
//  Copyright © 2016年 抠泥ser. All rights reserved.
//

#import "NormalTableViewCell.h"
#import <Masonry.h>
#import "PrefixHeader.pch"
#define CHEIGHT self.contentView.frame.size.height
#define CWIDTH self.contentView.frame.size.width
@implementation NormalTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
   self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.sv = [[UIView alloc] init];
        [_sv NightWithType:UIViewColorTypeNormal];
        [self.contentView addSubview:_sv];
        
        self.imgsrcImageView = [[UIImageView alloc] init];
        // _imgsrcImageView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_imgsrcImageView];
        
        self.titleLabel = [[UILabel alloc] init];
        // _titleLabel.backgroundColor = [UIColor redColor];
        [_titleLabel NightWithType:UIViewColorTypeNormal];
        [self.contentView addSubview:_titleLabel];
        
        self.digestLabel = [[UILabel alloc] init];
        _digestLabel.numberOfLines = 0;
        _digestLabel.font = [UIFont systemFontOfSize:14];
        [_digestLabel NightWithType:UIViewColorTypeNormal];
        _digestLabel.alpha = 0.5;
        // _digestLabel.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_digestLabel];
        
        self.ptimeLabel = [[UILabel alloc] init];
        // _ptimeLabel.backgroundColor =[UIColor greenColor];
        _ptimeLabel.font = [UIFont systemFontOfSize:14];
        [_ptimeLabel NightWithType:UIViewColorTypeNormal];
        _ptimeLabel.alpha = 0.5;
        [self.contentView addSubview:_ptimeLabel];
        
        self.replyCountLabel = [[UILabel alloc] init];
        _replyCountLabel.textAlignment = 2;
        _replyCountLabel.font = [UIFont systemFontOfSize:14];
        [_replyCountLabel NightWithType:UIViewColorTypeNormal];
        _replyCountLabel.alpha = 0.5;
        // _replyCountLabel.backgroundColor = [UIColor purpleColor];
        [self.contentView addSubview:_replyCountLabel];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    // Masonry适配
    [_sv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
    
    int padding = 5;
    
    [_imgsrcImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_sv).with.offset(padding);
        make.top.equalTo(_sv).with.offset(padding);
        make.bottom.equalTo(_sv).with.offset(-padding);
        make.width.mas_equalTo(@(CWIDTH / 3));
    }];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(_sv).with.insets(UIEdgeInsetsMake(10, (CWIDTH - 20) / 3 + 10 + 5, (CHEIGHT - 20) / 4 * 3 + 10, 10));
    }];
    [_digestLabel mas_makeConstraints:^(MASConstraintMaker *make) {
         make.edges.equalTo(_sv).with.insets(UIEdgeInsetsMake(10 + (CHEIGHT - 20) / 4, (CWIDTH - 20) / 3 + 10 + 5, (CHEIGHT - 20) / 4 + 10 , 10));
    }];
    [_ptimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(_sv).with.insets(UIEdgeInsetsMake(10 + (CHEIGHT - 20) / 4 * 3, (CWIDTH - 20) / 3 + 10 + 5, 10, (CWIDTH - ((CWIDTH - 20) / 3 + 10 + 5)) / 2));
    }];
    [_replyCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(_sv).with.insets(UIEdgeInsetsMake(10 + (CHEIGHT - 20) / 4 * 3, (CWIDTH - ((CWIDTH - 20) / 3 + 10 + 5)) / 2 + (CWIDTH - 20) / 3 + 10 + 5, 10, 10));
    }];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
